package com.muyu.product.controller;

import com.muyu.common.core.domain.R;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.domain.AjaxResult;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.product.domain.ProductBrand;
import com.muyu.product.domain.vo.ProductBrandVo;
import com.muyu.product.service.ProductBrandService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.muyu.common.core.utils.PageUtils.startPage;

/**
 * @ClassName ProductController
 * @Description 描述
 * @Author ShiYu.Cui
 * @Date 2024/3/26 20:30
 */
@RestController
@RequestMapping("product/brand")
@Api(tags = "商品品牌管理")
public class BrandController extends BaseController {

    @Autowired
    private ProductBrandService productBrandService;

    @PostMapping("/brandList")
    @ApiOperation("获取商品全部品牌")
    public R<List<ProductBrand>> brandList(@RequestBody ProductBrandVo productBrandVo){
        return productBrandService.brandList(productBrandVo);
    }

    @PostMapping("/addBrand")
    @ApiOperation("添加商品品牌")
    public R addBrand(@RequestBody ProductBrand productBrand){
        productBrandService.addBrand(productBrand);
        return R.ok();
    }

    @PostMapping("/updateBrand")
    @ApiOperation("修改商品品牌")
    public R updateBrand(@RequestBody ProductBrand productBrand){
        productBrandService.updateBrand(productBrand);
        return R.ok();
    }


    @GetMapping("/delBrand")
    @ApiOperation("删除商品品牌")
    public R delBrand(@RequestParam Integer id){
        productBrandService.delBrand(id);
        return R.ok();
    }

}
